package ldh.im.fxgui.component.cell;

import javafx.scene.Node;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import ldh.im.fxbase.data.pojo.ImModuleItem;

public class ModuleItemView extends StackPane {

    private ImModuleItem moduleItem;

    public ModuleItemView(ImModuleItem moduleItem) {
        this.moduleItem = moduleItem;
        this.getStyleClass().add("module-item");
        initUi();
    }

    private void initUi() {
        Node icon = buildIcon();
        Label name = new Label(moduleItem.getName());
        name.setGraphic(icon);
        name.setContentDisplay(ContentDisplay.TOP);
        this.getChildren().addAll(icon, name);
    }

    private Node buildIcon() {
        Image image = new Image(this.getClass().getResource("/imgs/notice.png").toExternalForm());
        ImageView imageView = new ImageView(image);
        imageView.setFitWidth(50);
        imageView.setFitHeight(50);
        return imageView;
    }
}
